package com.tencreat.mall.controller.im;

/**
 * 其他公共接口控制器
 *
 * @author zixin
 * @company 深圳腾创互联科技有限公司
 * @link https://tencreat.com
 * @since 2023/4/13 14:04
 */

import com.tencreat.common.core.HttpResult;
import com.tencreat.domain.im.ImPhrases;
import com.tencreat.domain.im.ImPhrasesType;
import com.tencreat.service.IImPhrasesTypeService;
import com.tencreat.service.im.IImPhrasesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/im/customer")
@Api(tags = "IM客服接口")
@RequiredArgsConstructor
public class ImApiController {

    private final IImPhrasesTypeService imPhrasesTypeService;
    private final IImPhrasesService imPhrasesService;

    @ApiOperation("获取常用语分类")
    @GetMapping("/phrases/type/list")
    HttpResult<List<ImPhrasesType>> phrasesTypeList() {
        return HttpResult.ok(imPhrasesTypeService.list());
    }

    @ApiOperation("获取常用语")
    @GetMapping("/phrases/list/{type}")
    HttpResult<List<ImPhrases>> phrasesList(@PathVariable String type) {
        List<ImPhrases> list = imPhrasesService.lambdaQuery().eq(ImPhrases::getTypeId, type).list();
        return HttpResult.ok(list);
    }

}
